package com.duyinone.demo.mvp.base;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.duyinone.demo.mvp.R;
import com.duyinone.demo.mvp.mvp.IModel;
import com.duyinone.demo.mvp.mvp.IPresenter;
import com.duyinone.demo.mvp.mvp.IView;

/**
 * Created by 杜晓鸣 on 2021/2/9
 * Creation time: 2021/2/9 23:21
 * Class Note:
 */
public class BaseActivity<P extends IPresenter> extends AppCompatActivity implements IView{

    protected P mPresenter;

    // 调用Activity的生命周期结束接口实现P层的资源释放
    @Override
    protected void onDestroy() {
        super.onDestroy();
        // 在释放前需判断P层是否有绑定，如果有绑定，执行P层的onDestroy函数
        if (mPresenter != null){
            mPresenter.onDestroy();
        }
        this.mPresenter = null;
    }

}
